# Plant classes for pyplant
if __debug__:
    from SimPy.SimulationTrace import *
else:
    from SimPy.Simulation import *

class Plant(Process):
    def __init__(self,name,dailywater,watersource):
        Process.__init__(self,name=name)
        self.dailywater = int(dailywater)
        self.watersource = watersource
        print "%s needs %d ml of water per day" % (name, self.dailywater)

    def grow(self):
        print now(), self.name, "Just Planted"
        while self.watersource.amount > self.dailywater:
            print now(), self.name, "Growin!"
            yield get, self, self.watersource, self.dailywater
            print now(), self.name, "Got %d ml of water!" % self.got
            yield hold, self, 24
        print now(), self.name, "Dyin :("
        yield hold, self, 20
        print now(), self.name, "Deads"

